package com.he.DesignPatterns.factory.demo;

/**
 * @description: TODO
 * @Author: HCL
 * @Date: 2024/8/26 9:29
 */
public class CoffeeStore {

    public Coffee selectCoffee(String type) {
        Coffee coffee = null;
        if ("A".equalsIgnoreCase(type)) {
            coffee = new AmericanCoffee();
        } else if ("B".equalsIgnoreCase(type)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException("没有该咖啡");
        }
        coffee.addMilk();
        coffee.addSugar();
        return coffee;
    }
}
